package cn.tedu.egaddress1.controller;

import cn.tedu.egaddress1.mapper.AddressMapper;
import cn.tedu.egaddress1.pojo.dto.AddressAddParam;
import cn.tedu.egaddress1.pojo.entity.Address;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("v1/address/")
public class AddressController {
    @Autowired
    private AddressMapper addressMapper;
    @PostMapping("add")
    public String add(AddressAddParam addressAddParam){
        System.out.println("addressAddParam="+addressAddParam);
        Address address = new Address();
        BeanUtils.copyProperties(addressAddParam,address);
        int i=addressMapper.insertAddress(address);

        if(i > 0)
        {
            return "添加成功";
        }

            return "添加失败";
        }
    }


